﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once

#include "GcmpDbCommonEdit.h"
#include "IElementDeletionContext.h"

namespace gcmp
{
    class ElementId;
    class IDocument;

    /// \brief 删除操作的工具类。
    ///     
    class GCMP_DB_COMMON_EDIT_EXPORT DeleteUtils
    {
    public:
#pragma region Static
        /// \brief Elements删除操作
        ///
        /// 如果待删除的element有多个，那么能被删除的element将被删除，不能被删除的将不会删除同时返回错误
        /// 如果所有elements都被成功删除，返回true，否则返回false
        /// \param pDocument 文档指针
        /// \param pElementDeletionContext 对象的删除上下文
        /// \param elementIdsToDelete 待删除的elementids
        /// \param pErrorMessages element删除操作失败时，返回的该element id及其删除错误信息
        /// \return 删除成功返回true，否则返回false
        static bool DeleteElements(IDocument* pDocument, const IElementDeletionContext* pElementDeletionContext, const std::vector<ElementId>& elementIdsToDelete, std::vector<std::pair<ElementId, std::wstring>>* pErrorMessages = nullptr);
#pragma endregion Static
    };
}

